<?php
/*********************************************************************************
* Filename: create_team.php
* 
* This PHP script validates input recieved from the user for creating a team,
* and if the input is valid inserts a new entry into the TEAMS table in the 
* database for the selected league.
*
*
* Author: Caleb Goff
* Date Created: 10/10/2009
**********************************************************************************/

//The common.php file contains 
include_once "common.php";

echo "$header_open";
echo "$css_create";
echo "$js_create_league";
echo "$header_close";

?>

<body onload="postLoad();">

<!-- Define pop up divs. -->
<div id="popupBadDraftDate" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Invalid draft date selected!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupBadDraftDate')">
</div>

<div id="popupBadLeagueName" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Invalid league name provided!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupBadLeagueName')">
</div>

<div id="popupBadLeaguePwd" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Invalid league password provided!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupBadLeaguePwd')">
</div>

<div id="popupBadInvites" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Invalid input for email invites!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupBadInvites')">
</div>

<div id="popupLeagueNameExists" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	A league by that name already exists!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupLeagueNameExists')">
</div>

<div id="popupLeagueSuccess" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Success!</b></u><br><br>
	You have successfully created your league!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupLeagueSuccess')">
</div>

<div id="popupInvaludInput" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Only alphanumeric characters are allowed, except the @ and .<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupInvaludInput')">
</div>

<!-- End defining popup divs -->

<div id="wrapper">
	<div id="inner">
		<div id="masthead">
			<h1>
			</h1>
			<ul>
				<?php 
					echo"$g_nav_bar";
				?>
			</ul>
		</div>

    	<div id="all_content">
			<h2>
                Create a League
			</h2>
			    Ready to start up your own Fantasy Broomball league for you and your friends? 
                Fill out the information below and get playing right away!
			<br><br>
			<i>Some things to keep in mind...</i>
			<ul>
                <li>- Leagues can have a maximum of <b>8</b> teams</li>
                <li>- Only alphanumeric characters are allowed</li>
            </ul>
			<h2>
				League Information
			</h2>

			<div id="info_box">
				<table>
					<form name="draft_form">
						<tr>
							<td class="input_title">League Name: </td>
							<td>
								<input class="resets" id="league_name" maxlength="32" size="12"/>
							</td>
							<td></td>
						</tr>
						<tr>
							<td class="input_title">League Password: </td>
							<td>
								<input class="resets" type="password" id="league_password" maxlength="16" size="12"/>
							</td>
							<td></td>
						</tr>
						<tr>
							<td class="input_title">Confirm Password: </td>
							<td>
								<input class="resets" type="password" id="confirm_league_password" maxlength="16" size="12"/>
							</td>
							<td></td>
						</tr>
						<tr>
							<td class="input_title">Draft Option: </td>
							<td>
								<input type="radio" name="draft_group" value="Live"> Live<br>
							</td>
							<td>
								<input type="radio" name="draft_group" value="Random"> Random<br>
							</td>
						</tr>
						<tr>
							<td class="input_title">Draft Date: </td>
							<td>
								<input disabled="disabled" class="resets" id="league_draft" name="draft_input" maxlength="10" size="12"/>
							</td>
							<td>
								<script language="JavaScript">
									new tcal ({
										// form name
										'formname': 'draft_form',
										// input name
										'controlname': 'draft_input'
									});
								</script>
							</td>
						<tr>
							<td class="input_title">Email Invites: </td>
							<td>
								<input class="resets" id="league_invites" size="12"/>
							</td>
							<td><i>Seperate each email address with a semi-colon (;)</i></td>
						</tr>
					</form>
				</table>
			</div>
			<div class="create_team_header">
				<input type="button" id="submit_create" value="Create League" onclick="checkCreateLeagueFields();" />
			</div>
	    </div>
		<h2></h2>
		<div id="footer">
			<?php echo "$footer"; ?>
		</div>
	</div>    
</div>
</body>
</html>
